<html>
	<head>
	<style>
	table, td, th {
		border: 1px solid black;
	}

	table {
		width: 75%;
	}
	</style>
	</head>
	<title>Final Report </title>
	<body>
	<p align="left">
		<font color="blue" size="4">IDENTITAS LAPORAN</font>
		<!-- Tabel Identitas Laporan-->
		<table border="1"> 
			<tr>
				<td>Provinsi : </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi()->getNama();?>&nbsp;</td>
			</tr>
			<tr>
				<td>Kab/Kota : </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getNama();?></td>
			</tr>
			<tr>
				<td>Desa: </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa() != null) echo $berkas->getPerpustakaan()->getDesa()->getNama();?></td>
			</tr>
			<tr>
				<td>Nama Perpustakaan : </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan() != null) echo $berkas->getPerpustakaan()->getNama();?></td>
			</tr>
			<tr>
				<td>Jenis Laporan : </td>
				<td colspan="3" style="width:70%"><?php echo $berkas->getTipe()->getNama();?></td>
			</tr>
			<tr>
				<td>Rincian Laporan: </td>
				<td colspan="3 style="width:70%""><?php if ($berkasTraining != null) 
															echo $berkasTraining->getJenisTraining()->getNama();
															
													?>&nbsp;</td>
			</tr>
			<?php
			$fromDate = "-";
			$toDate = "-";
			
			if ($berkasTraining != NULL){
				$fromDate = $berkasTraining->getFromDate()->format('d-m-Y');
				$toDate = $berkasTraining->getToDate()->format('d-m-Y');
			} else if ($berkasLkpm != NULL) {
				$fromDate = $berkasLkpm->getFromDate()->format('d-m-Y');
				$toDate = $berkasLkpm->getToDate()->format('d-m-Y');
			} else if ($berkasLas != NULL){
				$fromDate = $berkasLas->getFromDate()->format('d-m-Y');
				$toDate = $berkasLas->getToDate()->format('d-m-Y');
			}
			?>
			<tr>
				<td>Tanggal Kegiatan Dimulai : </td>
				<td><?=$fromDate?></td>
				<td>Tanggal Kegiatan Selesai : </td>
				<td><?=$toDate?></td>
			</tr>
		</table>
		<br>
		
		<!-- Table Jenis Kegiatan-->
		<?php if ($berkasLkpm != null) { ?>
		<table border="1"> 
			<tr>
				<td>Jenis Kegiatan : </td>
				<td colspan="2" style="width:70%"><?php if ($berkasLkpm != null) echo $berkasLkpm->getJenisKegiatan()->getNama()?></td>
			</tr>
			
			<tr>
				<td rowspan="7">Kelompok Sasaran :  </td>
				<td>&#10003;</td>
				
			<?php 
				  if (is_array($berkasLkpmSasarans) && count($berkasLkpmSasarans) > 0){
					  $i = 0;
					  foreach ($berkasLkpmSasarans as $row){
					  		if ($i = 0){
					  			echo '<td style="width:70%">'.$row->getNama().'</td>
									</tr>';											
					  		}  else {
					  			echo '<tr>
										<td>&#10003;</td>
										<td style="width:70%">Perempuan</td>
									</tr>';		
					  		}
							$i++;
					  }  	
				  }
			?>				
			
		</table>
		<?php } ?>
		<br>
		
		<?php if ($berkasLas != null) { ?>
		<!-- Table Jenis Asistensi-->
		<table border="1"> 
			<tr>
				<td>Jenis Asistensi : </td>
				<td colspan="2" style="width:70%"><?php if ($berkasLas != NULL){
															if ($berkasLas->getJenisAsistensi() == 1){
																$jenisAsistensi = "Non Kunjungan";
															} else {
																$jenisAsistensi = "Kunjungan";
															}
															echo $jenisAsistensi;
														}
													?></td>
			</tr>
			<tr>
				<td rowspan="6">Media Asistensi :  </td>
				<td>&#10003;</td>
				<td style="width:70%"><?=$berkasLas->getMedia()->getNama()?></td>
			</tr>
			<tr>
				<td rowspan="5">Kategori Asistensi :  </td>
				<td>&#10003;</td>
				<td style="width:70%"><?=$berkasLas->getKategoriAsistensi()->getNama()?></td>
			</tr>			
		</table>
		<?php } ?>
		<br>
	</p>
	<p align="left">
	<?php if ($berkasTraining != null) { ?>	
		<font color="blue" size="4">JUMLAH PESERTA</font>
		<!-- Tabel Jumlah Peserta -->
		<table border="1"> 
			<tr>
				<td colspan="2">Staf Perpustakaan</td>
				<td colspan="2">Non-Staf Perpustakaan</td>
				<td colspan="3">Total</td>
				<td rowspan="2">Lainnya</td>
			</tr> 
			<tr>
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Laki - Laki</td>
				<td>Perempuan</td>			
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Total</td>
			</tr>
			<?php
				$stafLaki = 0;
				$stafPr = 0;
				$nonstafLaki = 0;
				$nonstafPr = 0;
				$lainnya = 0;
				foreach ($memberOfTraining as $row){
					if ($row->getStaff() == "S"){
						if ($row->getGender() == "M"){
							$stafLaki++;
						} else if ($row->getGender()=="F"){
							$stafPr++;
						} 
					} else if ($row->getStaff() == "N") {
						if ($row->getGender() == "M"){
							$nonstafLaki++;
						} else if ($row->getGender()=="F"){
							$nonstafPr++;
						}
					} else {
						$lainnya++;
					}																				
				}  
				
				$laki = $stafLaki + $nonstafLaki;
				$pr = $stafPr + $nonstafPr;
				$total = $laki + $pr;
				if ($stafLaki <= 0){
					$stafLaki = "-";
				}
				
				if ($stafPr <= 0){
					$stafPr = "-";
				}
				
				if ($nonstafLaki <= 0){
					$nonstafLaki = "-";
				}
				
				if ($nonstafPr <= 0){
					$nonstafPr = "-";
				}
				
				if ($laki <= 0){
					$laki = "-";
				}
				
				if ($pr <= 0){
					$pr = "-";
				}
				
				if ($total <= 0){
					$total = "-";
				}
				
				if ($lainnya <= 0){
					$lainnya = "-";
				}
			?>
			<tr>
				<td><?=$stafLaki?></td>
				<td><?=$stafPr?></td>
				<td><?=$nonstafLaki?></td>
				<td><?=$nonstafPr?></td>			
				<td><?=$laki?></td>
				<td><?=$pr?></td>
				<td><?=$total?></td>
				<td><?=$lainnya?></td>
			</tr> 
		</table>
		<br>
		<?php } ?>
		<font color="blue" size="4">GAMBARAN KEGIATAN</font>
		<div>
			<?php
				echo $berkas->getDescription();
			?>
		</div>
		<br>
		<font color="blue" size="4">HASIL KEGIATAN</font>
		<div>
			<?php
				echo $berkas->getHasilKegiatan();
			?>
		</div>
		<br>
		<font color="blue" size="4">TANTANGAN KEGIATAN</font>
		<div>
			<?php
				echo $berkas->getTantangan();
			?>
		</div>
		<br>
		<font color="blue" size="4">LAMPIRAN</font>
		<div>
		<ol>
			<?php
				if (is_array($berkasAttachments) && count($berkasAttachments) > 0){
					//die('test');
					foreach ($berkasAttachments as $row){
						echo '<li>'.$row->getPath().'</li>';
					}
				}
				//die();
			?>			
		</ol>  
		</div>
		<br>
		<font color="blue" size="4">CATATAN TAMBAHAN</font>
		<table border="1"> 
			<tr>
				<td>Tanggal Laporan Dibuat:</td>
				<td><?php echo $berkas->getStartDate()->format('d-m-Y');?></td>
				<td>Tanggal Laporan Dikirimkan:</td>
				<td>&nbsp;</td>
			</tr> 
			<tr>
				<td>Tanggal Laporan Selesai Direview:</td>
				<td>&nbsp;</td>
				<td>Tanggal Laporan Disetujui:</td>
				<td><?php echo $berkas->getEndDate()->format('d-m-Y'); ?></td>
			</tr>
		</table>
	</p>
	</body>
</html>